package com.app.service.adapter;




import java.util.ArrayList;

import com.app.activity.R;
import com.app.data.YouhuiItem;
import com.app.service.adapter.ScenicAdapter.ScenicHandle;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class YouhuiAdapter extends DataAdapter{
	ArrayList<YouhuiItem> list;
	public YouhuiAdapter(Activity parentActivity,ArrayList<YouhuiItem> list) {
		this(parentActivity);
		this.list= list;
	}
	
	public YouhuiAdapter(Activity parentActivity) {
		super(parentActivity);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		YouhuiHandle handle;
		if (convertView == null) {
			convertView = LayoutInflater.from(parentActivity).inflate(R.layout.youhui_list_item, null);
			handle = new YouhuiHandle();
			handle.imageView = (ImageView)convertView.findViewById(R.id.tvyouhuiicon);
			handle.contentView = (TextView)convertView.findViewById(R.id.tvyouhuicontent);
			handle.priceView = (TextView)convertView.findViewById(R.id.tvyouhuicontentprice1);
			handle.pirceView2  =(TextView)convertView.findViewById(R.id.tvyouhuicontentprice2);
			convertView.setTag(handle);
		}else
		{
			handle = (YouhuiHandle)convertView.getTag();
		}
		
		YouhuiItem item = list.get(position);
		item.setContent(item.getContent());
		handle.imageView.setImageBitmap(item.getIconbitmap());
		handle.contentView.setText(item.getContent());
		handle.priceView.setText("原价："+item.getTicketPrice());
		handle.pirceView2.setText("优惠价："+item.getTicketPriceNew());
		return convertView;
	}
	class YouhuiHandle
	{
		ImageView imageView;
		TextView contentView;
		TextView priceView;
		TextView pirceView2;
	}
}
